﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
using static UnityDistantTerrain;
public class ET_ConfigManager
{
    public static QuestPOITeleData cfgDataTable;
    private static string filePath = Environment.CurrentDirectory + "\\Mods\\ET POI Quest Tele\\Setting\\cfg.json";
    public class QuestPOITeleData
    {
        [JsonProperty("ID")]
        public string ModuleID { get; set; }
        [JsonProperty("可使用POI任务点传送的最小距离(m)")]
        public float MinDistanceToTele { get; set; }
        [JsonProperty("传送等待时间(s)")]
        public float WaitToHandleActionSec { get; set; }
        [JsonProperty("是否可以在血月使用该功能(Boolen)")]
        public bool IsAvailableInBM { get; set; }
        [JsonProperty("是否全球广播玩家POI任务点传送讯息(Boolen)")]
        public bool GlobalBroadcastEnable { get; set; }
        [JsonProperty("返回任务POI传送出发点的指令(String)")]
        public string ChatCmdApiRequestBack { get; set; }
    }
    public static async Task<QuestPOITeleData> ReadCfgData()
    {
        return await Task.Run(() =>
        {
            if (File.Exists(filePath))
            {
                string json = File.ReadAllText(filePath);
                QuestPOITeleData questPOITeleData = JsonConvert.DeserializeObject<QuestPOITeleData>(json);
                return questPOITeleData;
            }
            return null;
        });
    }
}
